import request from '@/utils/request'
import { Connection } from '@/types/api/connection'




// 验证连接连通性
export const connectionVerify = (data: Connection) => {
  return request({
    url: '/connection/verify',
    method: 'post',
    data
  })
}

// 获取数据连接列表
export const connectionList = (data: any) => {
  return request({
    url: '/connection',
    method: 'get',
    data
  })
}

// 保存数据连接
export const connectionSave = (data: any) => {
  return request({
    url: '/connection',
    method: 'post',
    data
  })
}

// 删除数据连接
export const connectionDelete = (id: number) => {
  return request({
    url: `/connection/${id}`,
    method: 'delete'
  })
}

// 获取数据连接详情
export const connectionDetail = (id: number) => {
  return request({
    url: `/connection/${id}`,
    method: 'get'
  })
}

// 获取数据库下表列表
export const connectionPathTable = (id: number) => {
  return request({
    url: `/connection/${id}/path-tables`,
    method: 'post'
  })
}

// 获取表预览数据
export const connectionPathTableData = (id: number, data: any) => {
  return request({
    url: `/connection/${id}/path-table-data`,
    method: 'post',
    data
  })
}